<template>
    <el-main>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="昵称">
          <el-input v-model="form.uname"></el-input>
        </el-form-item>
        <el-form-item label="账号">
          <el-input v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input type="password" v-model="form.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即注册</el-button>
          <el-button @click="goback()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-main>
</template>

<script>
export default {
  name: "Enro",
  data() {
    return {
      form: {}
    }
  },
  methods: {
    onSubmit() {
      this.axios.post("http://localhost:9999/user/adduser",this.form).then((res)=>{
        if (res){
          this.$message.success("注册成功");
          this.$router.push({path:"/user"})
        }
      })
    },
    goback(){
      this.$router.push({path:"/user"})
    }
  }
}
</script>

<style scoped>

</style>